package edu.zhangxu.service;

import edu.zhangxu.dao.SubmitRecordDao;
import edu.zhangxu.dao.SubmitRecordDaoImp;
import edu.zhangxu.pojo.SubmitRecord;
import edu.zhangxu.util.JDBCUtils;

import java.sql.Connection;
import java.util.List;

public class SubmitRecordService {
    private int count = 25;

    public List<SubmitRecord> getSubmitRecords(int page) throws Exception {
        List<SubmitRecord> submitRecordList = null;
        Connection con = null;
        SubmitRecordDao dao = new SubmitRecordDaoImp();
        try {
            con = JDBCUtils.getConnection();
            submitRecordList = dao.getSubmitRecords(con, (page-1)*count, count);
        } finally {
            JDBCUtils.closeConnection(con, null);
        }
        return submitRecordList;
    }

    public long getSubmitRecordTotal() throws Exception {
        long total = 0;
        Connection con = null;
        SubmitRecordDao dao = new SubmitRecordDaoImp();
        try {
            con = JDBCUtils.getConnection();
            total = dao.getSubmitRecordTotal(con);
        } finally {
            JDBCUtils.closeConnection(con, null);
        }
        return total;
    }
}
